

#ifndef _OTA_DATA_JSON_H__
#define _OTA_DATA_JSON_H__

#include "stdint.h"
#include "stdbool.h"

#define STR_LEN_MAX_8 8
#define STR_LEN_MAX_16 16

#define MSG_TYPE_STR_LEN_MAX 16
#define MSG_NODE_ID_LEN_MAX 32
#define ECU_NAME_LEN_MAX STR_LEN_MAX_8
#define ECU_VERSION_LEN_MAX STR_LEN_MAX_8
#define MD5_LEN_MAX 64
#define URL_LEN_MAX 256
#define SLICE_COUNT_MAX 16 //最大文件切割数量

#define REQUEST_STR_LEN_MAX 32
#define DESCRBTION_STR_LEN_MAX REQUEST_STR_LEN_MAX
#define OTA_ECU_COUNT_MAX 8

//------------消息推送-------------
typedef struct
{
    uint8_t forceSta;
    bool velSta;
    bool chgSta;
    uint8_t gear[8];
    uint8_t speed;
    uint16_t minVolt;
    uint8_t minSOC;
    bool powerSta;

}t_otaPushCondition;

typedef struct
{
    uint32_t taskId;
    uint8_t ecuCount;
    t_otaPushCondition otaPushCondition;
}t_otaPushData;

typedef struct struct_otaPushMsg
{
    uint8_t mType[MSG_TYPE_STR_LEN_MAX];
    uint8_t mId[MSG_NODE_ID_LEN_MAX];
    uint8_t nId[MSG_NODE_ID_LEN_MAX];
    uint32_t unixTime;
    t_otaPushData data;
}t_otaPushMsg;


//-----------升级参数------
typedef struct
{
    uint8_t index;
    uint8_t ecu[ECU_NAME_LEN_MAX]; //ECU名
    uint8_t did[STR_LEN_MAX_16]; //设备ID
    uint8_t cid[STR_LEN_MAX_16]; //公司代码
    uint8_t hv[ECU_VERSION_LEN_MAX];
    uint8_t sv[ECU_VERSION_LEN_MAX];
}t_otaPm;
typedef struct
{
    uint32_t size;
    uint8_t md5[MD5_LEN_MAX];
    uint8_t url[URL_LEN_MAX];
    uint8_t slice;
    uint32_t ssize[SLICE_COUNT_MAX];
}t_otaFileUrlData;


typedef struct
{
    uint32_t taskId;
    uint8_t ecuCount;
    t_otaPm Pm;
    t_otaFileUrlData pF;
    t_otaFileUrlData dF;
    t_otaFileUrlData oF;
}t_otaParamData;


typedef struct struct_otaParamPushMsg
{
    uint8_t mType[MSG_TYPE_STR_LEN_MAX];
    uint8_t mId[MSG_NODE_ID_LEN_MAX];
    uint8_t nId[MSG_NODE_ID_LEN_MAX];
    uint32_t unixTime;
    t_otaParamData data;
}t_otaParamPushMsg;

//---------------------上发----------------------------
//消息头
typedef struct
{
    uint8_t mType[MSG_TYPE_STR_LEN_MAX];
    uint8_t mId[MSG_NODE_ID_LEN_MAX];
    uint8_t nId[MSG_NODE_ID_LEN_MAX];
    uint32_t unixTime;
    uint32_t taskId;
}t_otaAckHead;



//命令应答回传
typedef struct struct_otaAckMsg
{
    uint32_t taskId;
    uint8_t request[REQUEST_STR_LEN_MAX];
    uint8_t state;
    uint8_t descrbtion[DESCRBTION_STR_LEN_MAX];
    uint8_t sv[ECU_VERSION_LEN_MAX];
    uint8_t hv[ECU_VERSION_LEN_MAX];
    uint8_t ecuName[ECU_NAME_LEN_MAX];
}t_otaAckMsg;

typedef struct struct_otaCmdAck
{
    t_otaAckHead ackHead;
    t_otaAckMsg data;
}t_otaCmdAck;

//升级和下载状态
typedef struct struct_otaEcuState
{
    uint8_t ecuName[ECU_NAME_LEN_MAX];
    uint8_t state;
    uint8_t descrbtion[DESCRBTION_STR_LEN_MAX];
}t_otaEcuState;

typedef struct struct_otaStateAck
{
    t_otaAckHead ackHead;
    uint8_t request[REQUEST_STR_LEN_MAX];
    
    //t_otaEcuState ecuData[OTA_ECU_COUNT_MAX];
}t_otaStateAck;


//应用参数
//消息接收
extern t_otaPushMsg otaCmdMsgPkg;
extern t_otaParamPushMsg otaEcuParamMsgPkg;
//消息上传
extern t_otaCmdAck otaMsgAckPkg;       //消息接收完成返回




#endif











